this.BX=this.BX||{};this.BX.UI=this.BX.UI||{};(function(e,t){"use strict";var r=function(){function e(t,r,s,i,a){babelHelpers.classCallCheck(this,e);this.domNode=t;this.perimetr=r;this.radius=r/2;this.progressBar=Number(s)>100?100:s;this.progressBg=null;this.number=null;this.waves=null;this.leftWave=null;this.rightWave=null;this.fixCounter=i?i:null;this.withoutWaves=a?a:null}babelHelpers.createClass(e,[{key:"getCircumFerence",value:function e(){return(this.radius-10)*2*3.14}},{key:"getCircumProgress",value:function e(){return this.getCircumFerence()-this.getCircumFerence()/100*this.progressBar}},{key:"createCircle",value:function e(){this.svg=document.createElementNS("http://www.w3.org/2000/svg","svg");this.svg.setAttributeNS(null,"class","ui-graph-circle-bar");this.svg.setAttributeNS(null,"viewport","0 0 "+this.radius+" "+this.radius);this.svg.setAttributeNS(null,"width",this.perimetr);this.svg.setAttributeNS(null,"height",this.perimetr);this.progressBg=document.createElementNS("http://www.w3.org/2000/svg","circle");this.progressBg.setAttributeNS(null,"r",this.radius-10);this.progressBg.setAttributeNS(null,"cx",this.radius);this.progressBg.setAttributeNS(null,"cy",this.radius);this.progressBg.setAttributeNS(null,"class","ui-graph-circle-bar-bg");this.progressMove=document.createElementNS("http://www.w3.org/2000/svg","circle");this.progressMove.setAttributeNS(null,"r",this.radius-10);this.progressMove.setAttributeNS(null,"cx",this.radius);this.progressMove.setAttributeNS(null,"cy",this.radius);this.progressMove.setAttributeNS(null,"stroke-dasharray",this.getCircumFerence());this.progressMove.setAttributeNS(null,"stroke-dashoffset",this.getCircumFerence());this.progressMove.setAttributeNS(null,"class","ui-graph-circle-bar-progress");t.Dom.append(this.progressBg,this.svg);t.Dom.append(this.progressMove,this.svg);return this.svg}},{key:"animateFixedBar",value:function e(){this.svg.setAttributeNS(null,"class","ui-graph-circle-bar ui-graph-circle-bar-animate ui-graph-circle-bar-without-animate");this.progressMove.setAttributeNS(null,"stroke-dashoffset",0)}},{key:"animateProgressBar",value:function e(){this.svg.setAttributeNS(null,"class","ui-graph-circle-bar ui-graph-circle-bar-animate");this.progressMove.setAttributeNS(null,"stroke-dashoffset",this.getCircumProgress())}},{key:"createNumberBlock",value:function e(){this.number=t.Dom.create("div",{attrs:{className:"ui-graph-circle-number","data-progress":this.progressBar}});return this.number}},{key:"createWavesBlock",value:function e(){return t.Dom.create("div",{attrs:{className:"ui-graph-circle-waves-wrapper"},children:[this.waves=t.Dom.create("div",{attrs:{className:"ui-graph-circle-waves"},children:[this.leftWave=t.Dom.create("div",{attrs:{className:"ui-graph-circle-waves-left"}}),this.rightWave=t.Dom.create("div",{attrs:{className:"ui-graph-circle-waves-right"}})]})]})}},{key:"animateWavesBlock",value:function e(t){var r=this.progressBar;if(t){if(r<=50){r=45}if(r>50){r=85}this.progressBar<=25?r=25:null;this.waves.style.transform="translateY(-"+r+"%)"}this.progressBar<=25?r=25:null;this.waves.style.transform="translateY(-"+r+"%)"}},{key:"animateBothWaves",value:function e(){var t=0;var r=50;var s=15;var i;var a=Date.now();var u=1e3/s;var n;function h(){requestAnimationFrame(h);i=Date.now();n=i-a;if(n>u){a=i-n%u;var e=document.querySelector(".ui-graph-circle-waves-left");var s=document.querySelector(".ui-graph-circle-waves-right");t+=1;r-=1;e.style.transform="translate3d("+t+"%, 0, 0)";s.style.transform="translate3d("+r+"%, 0, 0)";if(parseInt(t,10)>=50){t=0}if(parseInt(r,10)<=0){r=50}}}h()}},{key:"createWrapper",value:function e(){this.graph=t.Dom.create("div",{attrs:{className:"ui-graph-circle-wrapper"}});t.Dom.append(this.createCircle(),this.graph);t.Dom.append(this.createNumberBlock(),this.graph);t.Dom.append(this.createWavesBlock(),this.graph);return this.graph}},{key:"addWrapperClass",value:function e(){t.Dom.addClass(this.graph,"ui-graph-circle-wrapper-animate");if(this.fixCounter){t.Dom.addClass(this.graph,"ui-graph-circle-counter")}}},{key:"animateNumber",value:function e(t){var r=this.progressBar;if(t){r=t}if(Number(r)<=0){if(t){this.number.innerHTML="0"}else{this.number.innerHTML="0"+" <span>%</span>"}return}if(t){this.number.innerHTML=t;this.number.innerHTML.length>=4?this.graph.classList.add("ui-graph-font-sm"):null}else{var s=0;var i=1e3/r;var a=setInterval(function(){s++;this.number.innerHTML=s+" <span>%</span>";s===Number(r)?clearInterval(a):null}.bind(this),i)}}},{key:"updateCounter",value:function e(t,r){this.progressBar=t;if(r){this.progressMove.setAttributeNS(null,"stroke-dashoffset",0)}else{this.progressMove.setAttributeNS(null,"stroke-dashoffset",this.getCircumProgress())}this.animateNumber(r);this.animateWavesBlock(r)}},{key:"show",value:function e(){t.Dom.append(this.createWrapper(),this.domNode);setTimeout(function(){this.addWrapperClass();this.animateNumber(this.fixCounter);if(this.fixCounter){this.animateFixedBar()}else{this.animateProgressBar()}if(this.withoutWaves){return}else{this.animateBothWaves();this.animateWavesBlock(this.fixCounter)}}.bind(this),500)}}]);return e}();e.Circle=r})(this.BX.UI.Graph=this.BX.UI.Graph||{},BX);
//# sourceMappingURL=ui.circle.bundle.map.js